package com.wiscamp.ninechapters.accounts.infrastructure.po;

import com.wiscamp.ninechapters.ddd.PersistenceObject;
import jakarta.persistence.*;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;

/**
 * 账户
 */
@Data
@jakarta.persistence.Entity
@Table(name = "account")
public class AccountPO implements PersistenceObject {
    private static final long serialVersionUID = 1L;

    @Transient
    private Collection<AccountBatchPO> accountBatches = new ArrayList<>();

    /**
     * 账户编号
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "account_id", insertable = false, nullable = false)
    private long accountId = 0;
    /**
     * 账户类型
     */
    @Column(name = "account_type", nullable = false)
    private int accountType = 0;
    /**
     * 用户编号
     */
    @Column(name = "user_id", nullable = false)
    private long userId = 0;
    /**
     * 余额
     */
    @Column(name = "balance", nullable = false)
    private BigDecimal balance = new BigDecimal(0);
    /**
     * 是否批次管理
     */
    @Column(name = "batch_management", nullable = false)
    private boolean batchManagement = false;
    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createTime;
    /**
     * 变更时间
     */
    @Column(name = "modified_time", nullable = false)
    private LocalDateTime editTime;
    /**
     * 时间标签
     */
    //@Column(name = "time_stamp", nullable = false)
    //private LocalDateTime timeStamp;
}